<?php
class Server {
	const PORT = 8811;

	public function prot(){
		$shell = "netstat -anp 2>/dev/null | grep ".self::PORT." | grep LISTEN | wc -l ";
		$result = shell_exec($shell);
		return $result;
	}
}
$server = new server();

swoole_timer_tick(2000,function($timer_id) use ($server){
	if (!$server->prot()) {
		echo "error";
	}else{
		echo 'success';
	}

});
